<?php

namespace App\Http\Controllers\Admin;

use App\Models\Admin\AdminUser;
use App\Tools\PrPdf;
use Illuminate\Http\Request;

class LoginController
{

    /**
     * 登录页
     * @param Request $request
     * @return
     */
    public function index(Request $request)
    {
        if ($request->isMethod('POST')) {
            $userName = $request->input('userName', '');
            $userPassword = $request->input('userPassword', '');
            if (empty($userPassword) || empty($userName)) {
                errorMsg('账号或密码不能为空');
            }
            //验证账号信息
            $re = AdminUser::isAdminUser($userName, $userPassword);
            if ($re) {
                successMsg("登录成功");
            }
            errorMsg("账号或密码错误");
        }
        return view('admin/public/login');
    }

    public function test()
    {
        $pdf = new PrPdf();
        $pdf->makePdf2();
    }

}
